﻿#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPushButton>
#include <QDialog>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_pushButton_clicked()
{
    //创建对话框
    QDialog* dialog = new QDialog(this);
    //设置大小和标题
    dialog->resize(400, 300);
    dialog->setWindowTitle("对话框");
    //显示对话框
    dialog->show();
    //设置关闭释放对象属性
    dialog->setAttribute(Qt::WA_DeleteOnClose);
}

